package cn.it.shop.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/***
 * 日期类型工具类
 * @author Administrator
 *
 */
public class DateUtil {
	
	/** 
     * 时间戳转换成日期格式字符串 
     * @param seconds 精确到秒的字符串 
     * @param formatStr 
     * @return 
     */  
    public static String timeStampDate(String seconds,String format) {  
        if(seconds == null || seconds.isEmpty() || seconds.equals("null")){  
            return "";  
        }  
        if(format == null || format.isEmpty()) format = "yyyy-MM-dd HH:mm:ss";  
        SimpleDateFormat sdf = new SimpleDateFormat(format);  
        return sdf.format(new Date(Long.valueOf(seconds+"000")));  
    } 
    
    

    /** 
    * 判断是否为合法的日期时间字符串 
    * @param str_input 
    * @return boolean;符合为true,不符合为false 
    */ 
	public static boolean isDate(String str_input,String rDateFormat){ 
		SimpleDateFormat formatter = new SimpleDateFormat(rDateFormat); 
		formatter.setLenient(false); 
		try { 
			formatter.format(formatter.parse(str_input)); 
		} catch (Exception e) { 
			return false; 
		} 
		return true; 

	}
	
}
